package zhihui.mobile.manager.shop;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import zhihui.mobile.bean.shop.sales.CouponInfo;
import zhihui.mobile.config.Config;
import zhihui.mobile.interfaces.net.IHttpCallBackListener;
import zhihui.mobile.manager.IManager;
import zhihui.mobile.manager.user.UserManager;
import zhihui.mobile.net.HttpUtils;

/**
 * Created by 张公铭 on 2017/9/5 0005.
 * 优惠券管理类
 */

public class CouponManager implements IManager
{
    private static CouponManager manager;
    private List<CouponInfo> mList = new ArrayList<>(); //确认订单可用折扣卷信息

    private CouponManager()
    {

    }

    private synchronized static void createIns()
    {
        if (manager == null)
        {
            manager = new CouponManager();
        }
    }

    public static CouponManager getInstance()
    {
        if (manager == null)
        {
            createIns();
        }
        return manager;
    }

    public List<CouponInfo> getmList()
    {
        return mList;
    }

    public void setmList(List<CouponInfo> list)
    {
        if (mList == null)
        {
            mList = new ArrayList<>();
        }
        mList.clear();
        mList.addAll(list);
    }

    public void getUseCouponList(IHttpCallBackListener listener, String skus, int money, int cityCode)
    {
        Map<String, String> params = new HashMap<>();
        params.put("service", "org.zhmm.app.api.order.Order");
        params.put("method", "findCouponByUserId");

        List<Object> list = new ArrayList<>();
        list.add(UserManager.getInstance().getCurUser().getId());
        list.add(skus);
        list.add(money);
        list.add(cityCode);

        HttpUtils.postAes(Config.URL, params, list, listener);
    }

    @Override
    public void clear()
    {

    }
}
